package cn.stylefeng.guns.modular.cooperationUnit.controller;

import cn.stylefeng.guns.modular.cooperationUnit.pojo.request.CooperationUnitRequest;
import cn.stylefeng.guns.modular.cooperationUnit.service.CooperationUnitService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 合作单位表控制器
 *
 * @author jizhongbao
 * @date 2022/01/10 15:08
 */
@RestController
@ApiResource(name = "合作单位表")
public class CooperationUnitController {

    @Resource
    private CooperationUnitService cooperationUnitService;

    /**
     * 添加
     *
     * @author jizhongbao
     * @date 2022/01/10 15:08
     */
    @PostResource(name = "添加", path = "/cooperationUnit/add")
    public ResponseData add(@RequestBody @Validated(CooperationUnitRequest.add.class) CooperationUnitRequest cooperationUnitRequest) {
        cooperationUnitService.add(cooperationUnitRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author jizhongbao
     * @date 2022/01/10 15:08
     */
    @PostResource(name = "删除", path = "/cooperationUnit/delete")
    public ResponseData delete(@RequestBody @Validated(CooperationUnitRequest.delete.class) CooperationUnitRequest cooperationUnitRequest) {
        cooperationUnitService.del(cooperationUnitRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author jizhongbao
     * @date 2022/01/10 15:08
     */
    @PostResource(name = "编辑", path = "/cooperationUnit/edit")
    public ResponseData edit(@RequestBody @Validated(CooperationUnitRequest.edit.class) CooperationUnitRequest cooperationUnitRequest) {
        cooperationUnitService.edit(cooperationUnitRequest);
        return new SuccessResponseData();
    }

    /**
     * 修改状态
     *
     * @author jizhongbao
     * @date 2022/01/10 15:08
     */
    @PostResource(name = "修改状态", path = "/cooperationUnit/changeStatus")
    public ResponseData changeStatus(@RequestBody @Validated(CooperationUnitRequest.changeStatus.class) CooperationUnitRequest cooperationUnitRequest) {
        cooperationUnitService.edit(cooperationUnitRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author jizhongbao
     * @date 2022/01/10 15:08
     */
    @GetResource(name = "查看详情", path = "/cooperationUnit/detail")
    public ResponseData detail(@Validated(CooperationUnitRequest.detail.class) CooperationUnitRequest cooperationUnitRequest) {
        return new SuccessResponseData(cooperationUnitService.detail(cooperationUnitRequest));
    }

    /**
     * 获取列表
     *
     * @author jizhongbao
     * @date 2022/01/10 15:08
     */
    @GetResource(name = "获取列表", path = "/cooperationUnit/list")
    public ResponseData list(CooperationUnitRequest cooperationUnitRequest) {
        return new SuccessResponseData(cooperationUnitService.findList(cooperationUnitRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author jizhongbao
     * @date 2022/01/10 15:08
     */
    @GetResource(name = "分页查询", path = "/cooperationUnit/page")
    public ResponseData page(CooperationUnitRequest cooperationUnitRequest) {
        return new SuccessResponseData(cooperationUnitService.findPage(cooperationUnitRequest));
    }

}